package data;

import java.util.Date;

import com.EntityName;
import com.google.appengine.api.datastore.Entity;

public class SubFlexiblePackage extends AbstractData{
	private long id = -1;
	private Date date;
	private double pricepernight;
	private double upchargeperperson;
	private double extrabed;
	private boolean inclusiveBreakfast;
	private long adult;
	private long child;
	
	public SubFlexiblePackage(){}
	
	public SubFlexiblePackage(long id){
		this.id = id;
	}
	
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public double getPricepernight() {
		return pricepernight;
	}
	public void setPricepernight(double pricepernight) {
		this.pricepernight = pricepernight;
	}
	public double getUpchargeperperson() {
		return upchargeperperson;
	}
	public void setUpchargeperperson(double upchargeperperson) {
		this.upchargeperperson = upchargeperperson;
	}
	public double getExtrabed() {
		return extrabed;
	}
	public void setExtrabed(double extrabed) {
		this.extrabed = extrabed;
	}
	
	public boolean isInclusiveBreakfast() {
		return inclusiveBreakfast;
	}

	public void setInclusiveBreakfast(boolean inclusiveBreakfast) {
		this.inclusiveBreakfast = inclusiveBreakfast;
	}

	public long getAdult() {
		return adult;
	}

	public void setAdult(long adult) {
		this.adult = adult;
	}

	public long getChild() {
		return child;
	}

	public void setChild(long child) {
		this.child = child;
	}

	@Override
	public Entity getEntity() {
		Entity item;
		if(this.key == null)
			item = new Entity(EntityName.SubFlexiblePackage);
		else
			item = new Entity(this.key);
		item.setProperty("Date", this.date);
		item.setProperty("PricePerNight", this.pricepernight);
		item.setProperty("UpChargePerPerson", this.upchargeperperson);
		item.setProperty("Extrabed", this.extrabed);
		item.setProperty("child", this.child);
		item.setProperty("adult", this.adult);
		item.setProperty("inclusiveBreakfast", this.inclusiveBreakfast);
		return item;
	}
	@Override
	public void setEntity(Entity entity) {
		this.id = entity.getKey().getId();
		this.date = (Date) entity.getProperty("Date");
		this.pricepernight = (Double) entity.getProperty("PricePerNight");
		this.upchargeperperson = (Double) entity.getProperty("UpChargePerPerson");
		this.extrabed = (Double) entity.getProperty("Extrabed");
		this.child = (Long) entity.getProperty("child");
		this.adult = (Long) entity.getProperty("adult");
		this.inclusiveBreakfast = (Boolean) entity.getProperty("inclusiveBreakfast");
		this.key = entity.getKey();
	}
	
	
	public void LoadData() {
		if (this.id > -1) {
			Entity entity = LoadData(EntityName.SubFlexiblePackage, this.id);
			setEntity(entity);
		}
	}
}
